package com.wang.controller;

import com.wang.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @Classname UserController
 * @Description TODO
 * @Date 2024/5/17 9:46
 * @Created by pc
 */
@Slf4j
@RestController
public class UserController {
    // 对象转json字符串  --- 序列化
    @GetMapping("/user/{salary}")
    public User getUser(@PathVariable("salary") Long salary){
        return new User("wang",30,true,new Date(),"程序员",salary);
    }

    // 反序列化  json - 转对象
    @RequestMapping("/user")
    public String getValue(@RequestBody User user){
        log.warn("user = {}" ,user.toString());
        return user.toString();
    }
}
